﻿using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;

public static class EncodingConverter
{
    [MenuItem("Tools/Convert Scripts to UTF-8")]
    public static void ConvertScriptsToUTF8()
    {
        string[] scriptFiles = Directory.GetFiles(Application.dataPath, "*.cs", SearchOption.AllDirectories);
        foreach (string scriptPath in scriptFiles)
        {
            string scriptContent = File.ReadAllText(scriptPath, Encoding.GetEncoding("GB2312"));
            File.WriteAllText(scriptPath, scriptContent, Encoding.UTF8);
        }
        Debug.Log("Scripts converted to UTF-8 encoding.");
    }
}